﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using QLTV_Public;

namespace QLTV_Data
{
  public  class DonVi_Data
    {
      KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
      public DataTable LayDuLieu()
      {
          return kn.LayDuLieu("Load_tbl_DonVi");
      }
      public int insert_DonVi(DonVi_Public tenDonVi,DonVi_Public ghiChu)
      {
          int Nparameter = 2;
          string[] name = new string[Nparameter];
          object[]value=new object[Nparameter];
          name[0] = "@TenDonVi";
          value[0] = tenDonVi.TenDonVi;
          name[1] = "@GhiChu";
          value[1] = ghiChu.GhiChu;
          return kn.update("Insert_DonVi",name,value,Nparameter);
      }
      public int update_DonVi(DonVi_Public maDonVi,DonVi_Public tenDonVi, DonVi_Public ghiChu)
      {
          int Nparameter = 3;
          string[] name = new string[Nparameter];
          object[] value = new object[Nparameter];
          name[0]="@MaDonVi";
          value[0]=maDonVi.MaDonVi;
          name[1] = "@TenDonVi";
          value[1] = tenDonVi.TenDonVi;
          name[2] = "@GhiChu";
          value[2] = ghiChu.GhiChu;
          return kn.update("Update_DonVi", name, value, Nparameter);
      }
      public int delete_DonVi(DonVi_Public maDonVi)
      {
          int Nparameter = 1;
          string[] name = new string[Nparameter];
          object[] value = new object[Nparameter];
          name[0] = "@MaDonVi";
          value[0] = maDonVi.MaDonVi;
          return kn.update("Delete_DonVi", name, value, Nparameter);
      }
    }
}
